import { getAjaxResultTypeEnumSchema } from '@/enums/ajaxResultTypeEnum';
import { AdColumn } from '@/components/AdVxeTable';
import { useI18n } from '@/hooks/web/useI18n';

const { t } = useI18n();
const ajaxResultTypeEnumSchema = getAjaxResultTypeEnumSchema();

export const columns: AdColumn[] = [
  {
    title: t('entity.idTitle'),
    field: 'Id',
    width: 0,
    visible: false,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('routes.system.audit.auditOperation.functionNameTitle'),
    field: 'FunctionName',
    width: 200,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditOperation.userIdTitle'),
    field: 'UserId',
    width: 200,
    visible: false,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditOperation.userNameTitle'),
    field: 'UserName',
    width: 150,
    formVisible: true,
    formEditable: false,
    filterable: true,
    filterIndex: 'UserId',
    filterJoin: {
      entityType: 'MicroCloud.Pack.Identity.Entities.User,MicroCloud.Pack.Identity',
      filterField: 'UserName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditOperation.userNicknameTitle'),
    field: 'UserNickname',
    width: 200,
    formVisible: true,
    formEditable: false,
    filterable: true,
    filterIndex: 'UserId',
    filterJoin: {
      entityType: 'MicroCloud.Pack.Identity.Entities.User,MicroCloud.Pack.Identity',
      filterField: 'NickName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditOperation.ipTitle'),
    field: 'Ip',
    width: 150,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditOperation.operationSystemTitle'),
    field: 'OperationSystem',
    width: 200,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditOperation.browserTitle'),
    field: 'Browser',
    width: 200,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditOperation.methodTitle'),
    field: 'Method',
    width: 80,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditOperation.contentTypeTitle'),
    field: 'ContentType',
    width: 150,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditOperation.queryStringTitle'),
    field: 'QueryString',
    width: 200,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'text',
    formCustomer: {
      colProps: {
        // span: 24,
        xs: 24, // <576px
        sm: 24, // ≥576px
        md: 24, // ≥768px
        lg: 24, // ≥992px
        xl: 24, // ≥1200px
        xxl: 24, // ≥1600px
        // xxxl: 24, // ≥2000px 3.0
      },
    },
  },
  {
    title: t('routes.system.audit.auditOperation.argumentsTitle'),
    field: 'Arguments',
    width: 200,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'text',
    formCustomer: {
      colProps: {
        // span: 24,
        xs: 24, // <576px
        sm: 24, // ≥576px
        md: 24, // ≥768px
        lg: 24, // ≥992px
        xl: 24, // ≥1200px
        xxl: 24, // ≥1600px
        // xxxl: 24, // ≥2000px 3.0
      },
    },
  },
  {
    title: t('routes.system.audit.auditOperation.messageTitle'),
    field: 'Message',
    width: 400,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'text',
    formCustomer: {
      colProps: {
        // span: 24,
        xs: 24, // <576px
        sm: 24, // ≥576px
        md: 24, // ≥768px
        lg: 24, // ≥992px
        xl: 24, // ≥1200px
        xxl: 24, // ≥1600px
        // xxxl: 24, // ≥2000px 3.0
      },
    },
  },
  {
    title: t('routes.system.audit.auditOperation.resultDataTitle'),
    field: 'ResultData',
    width: 200,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'text',
    formCustomer: {
      colProps: {
        // span: 24,
        xs: 24, // <576px
        sm: 24, // ≥576px
        md: 24, // ≥768px
        lg: 24, // ≥992px
        xl: 24, // ≥1200px
        xxl: 24, // ≥1600px
        // xxxl: 24, // ≥2000px 3.0
      },
    },
  },
  {
    title: t('routes.system.audit.auditOperation.resultTypeTitle'),
    field: 'ResultType',
    width: 200,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'enum',
    enumData: ajaxResultTypeEnumSchema,
  },
  {
    title: t('routes.system.audit.auditOperation.elapsedTitle'),
    field: 'Elapsed',
    width: 100,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'number',
  },
  {
    title: t('entity.creationAudited.createdTimeTitle'),
    field: 'CreatedTime',
    width: 150,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'datetime',
  },
];
